package com.homework;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;

public class Test03 {
    public static void main(String[] args) {
        HashSet<Person> objects = new HashSet<>();
        Person person1 = new Person("张三1",11);
        Person person2 = new Person("张三2",12);
        Person person3 = new Person("张三3",13);
        Person person4 = new Person("张三4",14);
        Person person5 = new Person("张三4",14);
        Collections.addAll(objects,person1,person2,person3,person4,person5);
        Iterator<Person> iterator = objects.iterator();
//        while (iterator.hasNext()){
//            Person next = iterator.next();
//            System.out.println(next);
//        }
        for (Person object : objects) {
            System.out.println(object.toString());
        }
    }
}
